<template>
  <div style="margin-bottom: 20px;">
    <el-dialog :title="edit_main_title" append-to-body v-dialogDrag :visible.sync="edit_flag"
               @open="handleOpenConfig" :before-close="handleClose" width="800px">
      <table id="" class="carTypeDetail" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td colspan="4">车牌号: {{titleData.plateLicenseNo | isHaveDataFilter}}</td>
          <td colspan="4">TBOX编号: {{titleData.tboxNo | isHaveDataFilter}}</td>
        </tr>
        <tr>
          <td colspan="4">当前经纬度: {{titleData.latLng | isHaveDataFilter}}</td>
          <td colspan="4">车辆状态:
           <span :class="[{'c-65ea8f': titleData.state === '10'},{'c-FFD700': titleData.state === '20'},
          {'c-ff340e': titleData.state === '30'}]">{{titleData.state | vehicleTypeFilter}}</span>
          </td>
        </tr>
        <tr>
          <td colspan="4">速度: {{titleData.vehicleSpeed | isHaveDataFilter}}km/h</td>
          <td colspan="4">里程: {{titleData.totalDistance | isHaveDataFilter}}km</td>
        </tr>
        <tr>
          <td colspan="4">剩余电量: {{titleData.vehBatSoc | isHaveDataFilter}}%</td>
          <td colspan="4">设备状态: {{titleData.deviceStatus | vehicleTypeFilter}}</td>
        </tr>
        <tr>
          <td colspan="4">疲劳驾驶: {{titleData.fatigueDriving | isHaveDataFilter}}</td>
          <td colspan="4">驾驶行为: {{titleData.drivingBehavior | isHaveDataFilter}}</td>
        </tr>
        <tr v-if="titleData.state === '20' || titleData.state === '30'">
          <td colspan="4">持续周期: {{titleData.duration}}分钟</td>
          <td colspan="4">备注: {{titleData.remark | isHaveDataFilter}}</td>
        </tr>
        <tr v-else>
          <td colspan="8" style="text-align: left">备注: {{titleData.remark | isHaveDataFilter}}</td>
        </tr>
      </table>
      <el-row type="flex" justify="end">
        <el-button type="primary" @click="handleClose">关闭</el-button>
      </el-row>
      <div style="height:20px"></div>
    </el-dialog>
  </div>
</template>

<script type="text/javascript">
  import * as MonitorMgtAPI from '@/api/monitor'
  export default {
    name: '',
    components: {},
    props: ['edit_flag', 'edit_main_title', 'edit_select_row', 'edit_params'],
    data() {
      return {
        shipmentIdzs: '',
        titleData: {
          plateLicenseNo: '',
          state: '', // 车辆状态
          tboxNo: '', // TBOX编号
          latLng: '',
          longitude: '', // 经度 英文：longitude  114.044815
          latitude: '', //  纬度 英文：latitude   22.687373
          vehicleSpeed: '', // 车速
          totalDistance: '', // 里程
          vehBatSoc: '', // 剩余电量
          duration: '', // 持续时间 单位分钟
          deviceStatus: '', // 设备状态
          fatigueDriving: '', // 疲劳驾驶
          drivingBehavior: '', // 驾驶行为
          remark: '' // 备注
        },
        tableData: []
      }
    },
    methods: {
      // 弹窗页打开初始
      handleOpenConfig(data) {
        this.getList()
      },
      getList() {
        const that = this
        const { rfId, vin, state } = this.$props.edit_select_row
        const toParams = { vin: vin, state: state, rfId: rfId }
        MonitorMgtAPI.getTabDetails(toParams).then(res => {
          that.titleData = res.data
        }).catch(err => {
          console.log('error', err)
          that.loadingShow = false
        })
      },
      handleClose() {
        this.$emit('edit-close', false)
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .c-65ea8f{
    color: #65ea8f;
  }
  .c-FFD700{
    color: #FFD700;
  }
  .c-ff340e{
    color: #ff340e;
  }
  .carTypeDetail{margin-left: auto;margin-right: auto;text-align: center;border-collapse:collapse;}
  .carTypeDetail>tr,.carTypeDetail>tr>th, .carTypeDetail>tr>td { border:1px solid #333;}
  .carTypeDetail>tr>td { padding:8px 6px !important;line-height: 26px;min-width: 240px;}
  .carTypeDetail>tr{
    text-align: center;
  }
</style>



